"""author: songzhiqiang
   data: 2021/12/10
   project: zuoye2
"""
#使用类实现迭代器，实现斐波拉契数列

class Fib:
    def __init__(self):
        self.a = 0
        self.b = 1

    def __iter__(self):
        return self

    def __next__(self):
        if self.a > 100:
            raise StopIteration("程序终止")
        self.a, self.b = self.b, self.a + self.b
        return self.a


f1 = Fib()
print(f1.__iter__())
for i in f1:
    print(i)
